import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard/homeIndex'
  },
  {
    path: '/dashboard',
    component: Layout,
    name: 'Dashboard',
    meta: { title: '首页', icon: 'el-icon-house' },
    children: [
      {
        path: 'homeIndex',
        name: 'homeIndex',
        meta: {
          title: '首页',
          icon: 'el-icon-house'
        },
        component: () => import('../views/home/home')
      },
      {
        path: 'board',
        name: 'board',
        meta: {
          title: '看板',
          icon: 'el-icon-s-grid'
        },
        component: () => import('../views/home/board')
      },
      {
        path: 'workbench',
        name: 'workbench',
        meta: {
          title: '工作台',
          icon: 'el-icon-set-up'
        },
        component: () => import('../views/home/workbench')
      },
      {
        path: 'warehouse',
        name: 'warehouse',
        meta: {
          title: '仓库',
          icon: 'el-icon-box'
        },
        component: () => import('../views/home/warehouse')
      }
    ]
  },
  {
    path: '/vab',
    component: Layout,
    redirect: '/vab/icon/fresh',
    name: 'Vab',
    meta: { title: '组件', icon: 'el-icon-set-up' },
    children: [
      {
        path: 'icon',
        name: 'Icon',
        redirect: '/vab/icon/fresh',
        component: () => import('@/views/element/icon/index'),
        meta: { title: '图标', icon: 'el-icon-aim' },
        children: [
          {
            path: 'fresh',
            name: 'Fresh',
            component: () => import('@/views/element/icon/Children/fresh'),
            meta: { title: '小清新图标' }
          },
          {
            path: 'iconSelector',
            name: 'iconSelector',
            component: () => import('@/views/element/icon/Children/iconSelector'),
            meta: { title: '图标选择器' }
          },
        ]
      },
      {
        path: 'table',
        name: 'Table',
        redirect: '/vab/table/synthesize',
        meta: { title: '表格', icon: 'el-icon-c-scale-to-original' },
        component: () => import('@/views/element/table'),
        children: [
          {
            path: 'synthesize',
            name: 'Synthesize',
            meta: { title: '综合表格' },
            component: () => import('@/views/element/table/Children/synthesize')
          },
          {
            path: '/vab/table/synthesize/detail',
            name: 'tableDetail',
            meta: { title: '详情页' },
            component: () => import('@/views/element/table/Children/tableDetail'),
            hidden: true
          },
          {
            path: 'inline',
            name: 'Inline',
            meta: { title: '行内编辑表格' },
            component: () => import('@/views/element/table/Children/inline')
          },
          {
            path: 'custom',
            name: 'Custom',
            meta: { title: '自定义表格' },
            component: () => import('@/views/element/table/Children/custom')
          },
          {
            path: 'dynamicTable',
            name: 'dynamicTable',
            meta: { title: '动态表格' },
            component: () => import('@/views/element/table/Children/dynamicTable')
          }
        ]
      },
      {
        path: 'card',
        name: 'Card',
        meta: { title: '卡片', icon: 'el-icon-postcard' },
        component: () => import('@/views/element/card')
      },
      {
        path: 'list',
        name: 'List',
        meta: { title: '列表', icon: 'el-icon-printer' },
        component: () => import('@/views/element/list')
      },
      {
        path: 'describe',
        name: 'Describe',
        meta: { title: '描述', icon: 'el-icon-reading' },
        component: () => import('@/views/element/describe')
      },
      {
        path: 'calendar',
        name: 'Calendar',
        meta: { title: '日历', icon: 'el-icon-date' },
        component: () => import('@/views/element/calendar')
      },
      {
        path: 'signature',
        name: 'Signature',
        meta: { title: '电子签名', icon: 'el-icon-edit-outline' },
        component: () => import('@/views/element/signature')
      },
      {
        path: 'map',
        name: 'Map',
        meta: { title: '地图', icon: 'el-icon-map-location' },
        component: () => import('@/views/element/map')
      },
      {
        path: 'magnifier',
        name: 'Magnifier',
        meta: { title: '放大镜', icon: 'el-icon-search' },
        component: () => import('@/views/element/magnifier')
      },
      {
        path: 'verify',
        name: 'Verify',
        meta: { title: '验证码', icon: 'terminal-box-line' },
        component: () => import('@/views/element/verify')
      },
      {
        path: 'editor',
        name: 'Editor',
        redirect: '/vab/editor/richText',
        meta: { title: '编辑器', icon: 'el-icon-edit' },
        component: () => import('@/views/element/editor'),
        children: [
          {
            path: 'richText',
            name: 'richText',
            meta: { title: '富文本编辑器' },
            component: () => import('@/views/element/editor/Children/richText')
          },
          {
            path: 'tencent',
            name: 'Tencent',
            meta: { title: '腾讯文档' },
            component: () => import('@/views/element/editor/Children/tencent')
          }
        ]
      },
      {
        path: 'from',
        name: 'From',
        redirect: '/vab/from/comprehensiveForm',
        meta: { title: '表单', icon: 'el-icon-document' },
        component: () => import('@/views/element/from'),
        children: [

          {
            path: 'comprehensiveForm',
            name: 'comprehensiveForm',
            meta: {
              title: '综合表单'
            },
            component: () => import('../views/element/from/Children/comprehensiveForm')
          },
          {
            path: 'distribution',
            name: 'distribution',
            meta: {
              title: '分布表单'
            },
            component: () => import('../views/element/from/Children/distribution')
          },
          {
            path: 'fromBtn',
            name: 'fromBtn',
            meta: {
              title: '按钮'
            },
            component: () => import('../views/element/from/Children/fromBtn')
          },
          {
            path: 'fromIpt',
            name: 'fromIpt',
            meta: {
              title: '输入框'
            },
            component: () => import('../views/element/from/Children/fromIpt')
          },

          {
            path: 'checkbox',
            name: 'checkbox',
            meta: {
              title: '多选框'
            },
            component: () => import('../views/element/from/Children/checkbox')
          },
          {
            path: 'counter',
            name: 'counter',
            meta: {
              title: '计数器'
            },
            component: () => import('../views/element/from/Children/counter')
          },

          {
            path: 'radio',
            name: 'radio',
            meta: {
              title: '单选框'
            },
            component: () => import('../views/element/from/Children/radio')
          },
          {
            path: 'slide',
            name: 'slide',
            meta: {
              title: '滑块'
            },
            component: () => import('../views/element/from/Children/slide')
          },
          {
            path: 'selector',
            name: 'selector',
            meta: {
              title: '选择器'
            },
            component: () => import('../views/element/from/Children/selector')
          },
          {
            path: 'switch',
            name: 'switch',
            meta: {
              title: '开关'
            },
            component: () => import('../views/element/from/Children/switch')
          },
          {
            path: 'textLink',
            name: 'textLink',
            meta: {
              title: '文字链接'
            },
            component: () => import('../views/element/from/Children/textLink')
          },
          {
            path: 'schedule',
            name: 'schedule',
            meta: {
              title: '时间选择器'
            },
            component: () => import('../views/element/from/Children/schedule')
          },
          {
            path: 'date',
            name: 'date',
            meta: {
              title: '日期选择器'
            },
            component: () => import('../views/element/from/Children/date')
          },
          {
            path: 'dateTime',
            name: 'dateTime',
            meta: {
              title: '日期时间选择器'
            },
            component: () => import('../views/element/from/Children/dateTime')
          },
          {
            path: 'rate',
            name: 'Rate',
            meta: {
              title: '评分'
            },
            component: () => import('../views/element/from/Children/rate')
          }
        ]
      }
    ]
  },
  {
    path: '/other',
    component: Layout,
    redirect: '/other/workflow/bpmn',
    name: 'Other',
    meta: {
      title: '其他',
      icon: 'el-icon-takeaway-box'
    },
    children: [
      {
        path: 'workflow',
        name: 'workflow',
        redirect: '/other/workflow/bpmn',
        meta: { title: '工作流', icon: 'flowChart' },
        component: () => import('@/views/other/workflow'),
        children: [
          {
            name:'Bpmn',
            path : 'bpmn',
            meta: { title: 'Bpmn'},
            component: () => import('@/views/other/workflow/bpmn'),
          },
          {
            name:'LogicFlow',
            path : 'LogicFlow',
            meta: { title: 'LogicFlow'},
            component: () => import('@/views/other/workflow/LF/index'),
          }
        ]
      },
      {
        path: 'echarts',
        name: 'Echarts',
        meta: { title: '图表', icon: 'chart' },
        component: () => import('@/views/other/echarts')
      },
      {
        path: 'print',
        name: 'Print',
        meta: { title: '打印', icon: 'printer' },
        component: () => import('@/views/other/print')
      },
      {
        path: 'cropper',
        name: 'Copper',
        meta: { title: '头像裁剪', icon: 'crop-line' },
        component: () => import('@/views/other/cropper')
      },
      {
        path: 'notice',
        name: 'Notice',
        meta: { title: '通知', icon: 'message' },
        component: () => import('@/views/other/notice')
      },
      {
        path: 'timeline',
        name: 'Timeline',
        meta: { title: '时间线', icon: 'time-line' },
        component: () => import('@/views/other/timeline')
      },
      {
        path: 'count',
        name: 'Count',
        meta: { title: '数字自增长', icon: 'number-9' },
        component: () => import('@/views/other/count')
      },
      {
        path: 'watermark',
        name: 'Watermark',
        meta: { title: '水印', icon: 'water-flash-line' },
        component: () => import('@/views/other/watermark')
      },
      {
        path: 'share',
        name: 'Share',
        meta: { title: '分享', icon: 'share-line' },
        component: () => import('@/views/other/share')
      },
      {
        path: 'dynamicAnchor',
        name: 'dynamicAnchor',
        meta: { title: '动态锚点', icon: 'anchor-line' },
        component: () => import('@/views/other/dynamicAnchor')
      },
      {
        path: 'dynamicMeta',
        name: 'dynamicMeta',
        meta: { title: '动态标题', icon: 'el-icon-news' },
        component: () => import('@/views/other/dynamicMeta')
      },
      {
        path: 'drag',
        name: 'Drag',
        redirect: '/other/drag/dialogDrag',
        meta: { title: '拖拽', icon: 'drag-drop-line' },
        component: () => import('@/views/other/drag'),
        children: [
          {
            path: 'dialogDrag',
            name: 'dialogDrag',
            meta: { title: '弹窗拖拽' },
            component: () => import('@/views/other/drag/Children/dialogDrag')
          },
          {
            path: 'cardDrag',
            name: 'cardDrag',
            meta: { title: '卡片拖拽' },
            component: () => import('@/views/other/drag/Children/cardDrag')
          }
        ]
      },
      {
        path: 'player',
        name: 'Player',
        meta: { title: '视频播放器', icon: 'video-line' },
        component: () => import('@/views/other/player')
      },
      {
        path: 'upload',
        name: 'Upload',
        meta: { title: '上传', icon: 'chat-upload-line' },
        component: () => import('@/views/other/upload')
      },
      {
        path: 'cssfx',
        name: 'Cssfx',
        meta: { title: 'Css动画', icon: 'css3-line' },
        component: () => import('@/views/other/cssfx')
      },
      {
        path: 'iframe',
        name: 'Iframe',
        redirect: '/other/iframe/authorization',
        meta: { title: 'iframe', icon: 'window-line' },
        component: () => import('@/views/other/iframe'),
        children: [
          {
            name:'360',
            path: '360',
            meta: { title: '360搜索' ,icon : 'search-line'},
            component: () => import('@/views/other/iframe/Children/360'),
          },
          {
            name:'Bilibili',
            path: 'bilibili',
            meta: { title: 'bilibili',icon:'bilibili-line' },
            component: () => import('@/views/other/iframe/Children/bilibili'),
          },
          {
            name:'Authorization',
            path: 'authorization',
            meta: { title: '自定义iframe',icon : 'google-fill' },
            component: () => import('@/views/other/iframe/Children/authorization'),
          },
        ]
      },
      {
        path: 'excel',
        name: 'Excel',
        redirect: '/other/excel/exportExcel',
        meta: { title: 'Excel', icon: 'file-excel-2-line' },
        component: () => import('@/views/other/excel'),
        children: [
          {
            path: 'exportExcel',
            name: 'exportExcel',
            meta: { title: '导出Excel' },
            component: () => import('@/views/other/excel/Children/exportExcel')
          },
          {
            path: 'exportSelectedExcel',
            name: 'exportSelectedExcel',
            meta: { title: '导出选中行Excel' },
            component: () => import('@/views/other/excel/Children/exportSelectedExcel')
          },
        ]
      }
    ]
  },
  {
    path: '/setting',
    component: Layout,
    redirect: '/setting/personalCenter',
    name: 'Setting',
    meta: {
      title: '配置',
      icon: 'el-icon-user'
    },
    children: [
      {
        path: 'personalCenter',
        name: 'personalCenter',
        meta: { title: '个人中心', icon: 'pinUser' },
        component: () => import('@/views/setting/personalCenter')
      },
      {
        path: 'userManagement',
        name: 'userManagement',
        meta: { title: '用户管理', icon: 'user-3' },
        component: () => import('@/views/setting/userManagement')
      },
      {
        path: 'roleManagement',
        name: 'roleManagement',
        meta: { title: '角色管理', icon: 'admin-line' },
        component: () => import('@/views/setting/roleManagement')
      },
      {
        path: 'departmentManagement',
        name: 'departmentManagement',
        meta: { title: '部门管理', icon: 'group-line' },
        component: () => import('@/views/setting/departmentManagement')
      },
      {
        path: 'menuManagement',
        name: 'menuManagement',
        meta: { title: '菜单管理', icon: 'menu-2-line' },
        component: () => import('@/views/setting/menuManagement')
      },
      {
        path: 'taskManagement',
        name: 'taskManagement',
        meta: { title: '任务管理', icon: 'task-line' },
        component: () => import('@/views/setting/taskManagement')
      },
      {
        path: 'systemLog',
        name: 'systemLog',
        meta: { title: '系统管理', icon: 'file-shield-2-line' },
        component: () => import('@/views/setting/systemLog')
      },
    ]
  },
  {
    path: '/tools',
    component: Layout,
    redirect: '/tools/eyeDropper',
    name: 'Tools',
    meta: {
      title: '工具',
      icon: 'el-icon-setting'
    },
    children: [
      {
        path: 'eyeDropper',
        name: 'eyeDropper',
        meta: { title: '取色器', icon: 'water-flash-line' },
        component: () => import('@/views/tools/eyeDropper')
      },
      {
        path: 'speechSynthesis',
        name: 'speechSynthesis',
        meta: { title: '语音合成', icon: 'customer-service-line' },
        component: () => import('@/views/tools/speechSynthesis')
      },
    ]
  },
  {
    path: 'external-link',
    component: Layout,
    meta: { title: 'External Link' },
    children: [
      {
        path: '/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
